home *** CD-ROM | disk | FTP | other *** search
/ Scene 96 / Scene 96 International Edition (Zyklop Software) (Disc 2) (1997).iso / misc / coding / midas060 / src / dpmi.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-16  |  8.9 KB  |  310 lines

  1. /*      DPMI.H
  2.  *
  3.  * DPMI functions for protected mode MIDAS
  4.  *
  5.  * $Id: dpmi.h,v 1.2 1997/01/16 18:41:59 pekangas Exp $
  6.  *
  7.  * Copyright 1996,1997 Housemarque Inc.
  8.  *
  9.  * This file is part of the MIDAS Sound System, and may only be
  10.  * used, modified and distributed under the terms of the MIDAS
  11.  * Sound System license, LICENSE.TXT. By continuing to use,
  12.  * modify or distribute this file you indicate that you have
  13.  * read the license and understand and accept it fully.
  14. */
  15.  
  16.  
  17. #ifndef __DPMI_H
  18. #define __DPMI_H
  19.  
  20.  
  21. /* new errors:
  22.         errDPMIFailure                  DPMI failure
  23.         errInvalidDescriptor            invalid segment descriptor
  24.  */
  25.  
  26.  
  27.  
  28. /****************************************************************************\
  29. *       struct dpmiRealCallRegs
  30. *       -----------------------
  31. * Description:  Real mode calling register value structure
  32. \****************************************************************************/
  33.  
  34. typedef struct
  35. {
  36.     ulong       rEDI;
  37.     ulong       rESI;
  38.     ulong       rEBP;
  39.     ulong       reserved;
  40.     ulong       rEBX;
  41.     ulong       rEDX;
  42.     ulong       rECX;
  43.     ulong       rEAX;
  44.     ushort      flags;
  45.     ushort      rES;
  46.     ushort      rDS;
  47.     ushort      rFS;
  48.     ushort      rGS;
  49.     ushort      rIP;
  50.     ushort      rCS;
  51.     ushort      rSP;                    /* if SS and SP are zero, DPMI will */
  52.     ushort      rSS;                    /* provide a small (30 words) stack */
  53. } dpmiRealCallRegs;
  54.  
  55.  
  56.  
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60.  
  61.  
  62.  
  63. /****************************************************************************\
  64. *
  65. * Function:     int dpmiAllocDescriptor(unsigned *descriptor);
  66. *
  67. * Description:  Allocate LDT descriptor. Use dpmiFreeDescriptor to deallocate.
  68. *
  69. * Input:        unsigned *descriptor    pointer to descriptor number
  70. *
  71. * Returns:      MIDAS error code. Descriptor number is written to *descriptor.
  72. *
  73. \****************************************************************************/
  74.  
  75. int CALLING dpmiAllocDescriptor(unsigned *descriptor);
  76.  
  77.  
  78.  
  79.  
  80. /****************************************************************************\
  81. *
  82. * Function:     int dpmiFreeDescriptor(unsigned descriptor);
  83. *
  84. * Description:  Deallocates an LDT descriptor.
  85. *
  86. * Input:        unsigned descriptor     descriptor to deallocate
  87. *
  88. * Returns:      MIDAS error code
  89. *
  90. \****************************************************************************/
  91.  
  92. int CALLING dpmiFreeDescriptor(unsigned descriptor);
  93.  
  94.  
  95.  
  96.  
  97. /****************************************************************************\
  98. *
  99. * Function:     int dpmiSetSegmentBase(unsigned selector, ulong baseAddr);
  100. *
  101. * Description:  Changes the 32-bit linear base address of a selector.
  102. *
  103. * Input:        unsigned selector       selector number
  104. *               ulong baseAddr          32-bit linear base address for
  105. *                                       selector
  106. *
  107. * Returns:      MIDAS error code.
  108. *
  109. \****************************************************************************/
  110.  
  111. int CALLING dpmiSetSegmentBase(unsigned selector, ulong baseAddr);
  112.  
  113.  
  114.  
  115.  
  116. /****************************************************************************\
  117. *
  118. * Function:     int dpmiGetSegmentBase(unsigned selector, ulong *baseAddr);
  119. *
  120. * Description:  Reads the 32-bit linear base address of a selector.
  121. *
  122. * Input:        unsigned selector       selector number
  123. *               ulong *baseAddr         pointer to the 32-bit linear base
  124. *                                       address of the selector
  125. *
  126. * Returns:      MIDAS error code. Selector base address is written to
  127. *               *baseAddr.
  128. *
  129. \****************************************************************************/
  130.  
  131. int CALLING dpmiGetSegmentBase(unsigned selector, ulong *baseAddr);
  132.  
  133.  
  134.  
  135.  
  136. /****************************************************************************\
  137. *
  138. * Function:     int dpmiSetSegmentLimit(unsigned selector, ulong limit);
  139. *
  140. * Description:  Changes the limit of a segment selector.
  141. *
  142. * Input:        unsigned selector       selector number
  143. *               ulong limit             32-bit segment limit
  144. *
  145. * Returns:      MIDAS error code.
  146. *
  147. \****************************************************************************/
  148.  
  149. int CALLING dpmiSetSegmentLimit(unsigned selector, ulong limit);
  150.  
  151.  
  152.  
  153.  
  154. /****************************************************************************\
  155. *
  156. * Function:     int dpmiSetSegmentAccessRights(unsigned selector,
  157. *                   unsigned accessRights);
  158. *
  159. * Description:  Changes the access rights of a selector
  160. *
  161. * Input:        unsigned selector       selector
  162. *               unsigned accessRights   new access rights for the segment
  163. *
  164. * Returns:      MIDAS error code.
  165. *
  166. \****************************************************************************/
  167.  
  168. int CALLING dpmiSetSegmentAccessRights(unsigned selector,
  169.     unsigned accessRights);
  170.  
  171.  
  172.  
  173.  
  174. /****************************************************************************\
  175. *
  176. * Function:     int dpmiCreateCodeAlias(unsigned codeSelector,
  177. *                   unsigned *selector);
  178. *
  179. * Description:  Creates a data descriptor that has the same base and limit
  180. *               as a code segment descriptor. Use dpmiFreeDescriptor() to
  181. *               deallocate data descriptor.
  182. *
  183. * Input:        unsigned codeSelector   code segment selector
  184. *               unsigned *selector      pointer to data segment selector
  185. *
  186. * Returns:      MIDAS error code. New data selector is written to *selector.
  187. *
  188. \****************************************************************************/
  189.  
  190. int CALLING dpmiCreateCodeAlias(unsigned codeSelector, unsigned *selector);
  191.  
  192.  
  193.  
  194.  
  195. /****************************************************************************\
  196. *
  197. * Function:     int dpmiAllocDOSMem(unsigned numParagraphs, unsigned *segment,
  198. *                   unsigned *selector);
  199. *
  200. * Description:  Allocates memory from DOS free memory pool, below 1MB. Use
  201. *               dpmiFreeDOSMem() to deallocate.
  202. *
  203. * Input:        unsigned numParagraphs  number of paragraphs to allocate
  204. *               unsigned *segment       pointer to real mode segment
  205. *               unsigned *selector      pointer to selector
  206. *
  207. * Returns:      MIDAS error code. Real mode segment of allocated block is
  208. *               written to *segment. Protected mode selector for block is
  209. *               written to *selector.
  210. *
  211. \****************************************************************************/
  212.  
  213. int CALLING dpmiAllocDOSMem(unsigned numParagraphs, unsigned *segment,
  214.     unsigned *selector);
  215.  
  216.  
  217.  
  218.  
  219. /****************************************************************************\
  220. *
  221. * Function:     dpmiFreeDOSMem(unsigned selector);
  222. *
  223. * Description:  Deallocates memory allocated with dpmiAllocDOSMem().
  224. *
  225. * Input:        unsigned selector       selector for allocated block
  226. *
  227. * Returns:      MIDAS error code
  228. *
  229. \****************************************************************************/
  230.  
  231. int CALLING dpmiFreeDOSMem(unsigned selector);
  232.  
  233.  
  234.  
  235.  
  236. /****************************************************************************\
  237. *
  238. * Function:     int dpmiRealModeInt(unsigned intNum,
  239. *                   dpmiRealCallRegs *registers);
  240. *
  241. * Description:  Simulates a real mode interrupt using DPMI service 0x0300.
  242. *               *register MUST contain appropriate register values for
  243. *               interrupt (CS:IP is ignored).
  244. *
  245. * Input:        unsigned intNum                 interrupt number
  246. *               dpmiRealCallRegs *registers     DPMI real mode calling struct
  247. *
  248. * Returns:      MIDAS error code. Register values returned by the interrupt
  249. *               are written to *registers.
  250. *
  251. \****************************************************************************/
  252.  
  253. int CALLING dpmiRealModeInt(unsigned intNum, dpmiRealCallRegs *registers);
  254.  
  255.  
  256.  
  257.  
  258. /****************************************************************************\
  259. *
  260. * Function:     int dpmiLockMemory(ulong start, ulong numBytes);
  261. *
  262. * Description:  Locks a region of memory to prevent it from being paged. The
  263. *               memory can be unlocked using dpmiUnlockMemory().
  264. *
  265. * Input:        ulong start             memory region start address
  266. *               ulong numBytes          memory region length in bytes
  267. *
  268. * Returns:      MIDAS error code
  269. *
  270. \****************************************************************************/
  271.  
  272. int CALLING dpmiLockMemory(ulong start, ulong numBytes);
  273.  
  274.  
  275.  
  276.  
  277. /****************************************************************************\
  278. *
  279. * Function:     int dpmiUnlockMemory(ulong start, ulong numBytes);
  280. *
  281. * Description:  Unlocks a region of memory locked with dmpiLockMemory().
  282. *
  283. * Input:        ulong start             memory region start address
  284. *               ulong numBytes          memory region length in bytes
  285. *
  286. * Returns:      MIDAS error code
  287. *
  288. \****************************************************************************/
  289.  
  290. int CALLING dpmiUnlockMemory(ulong start, ulong numBytes);
  291.  
  292.  
  293.  
  294. #ifdef __cplusplus
  295. }
  296. #endif
  297.  
  298.  
  299.  
  300. #endif
  301.  
  302. /*
  303.  * $Log: dpmi.h,v $
  304.  * Revision 1.2  1997/01/16 18:41:59  pekangas
  305.  * Changed copyright messages to Housemarque
  306.  *
  307.  * Revision 1.1  1996/05/22 20:49:33  pekangas
  308.  * Initial revision
  309.  *
  310. */